Telegram Group & Telegram Channel
🗃 Работа с файлами и файловой системой в C++17

Хочешь получить список файлов в папке? std::filesystem предоставляет удобные итераторы для обхода директории. Особенно полезно при создании загрузчиков ассетов, инструментов или скриптов, работающих с файлами.


✏️ Решение:

1. заголовочный файл <filesystem>
2. Используй directory_iterator для обхода содержимого папки
3. Проверь тип объекта (файл, директория и т.д.), если нужно отфильтровать только файлы

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main() {
std::string path = "."; // текущая директория

for (const auto& entry : fs::directory_iterator(path)) {
if (fs::is_regular_file(entry)) {
std::cout << "Файл: " << entry.path() << std::endl;
}
else if (fs::is_directory(entry)) {
std::cout << "Папка: " << entry.path() << std::endl;
}
}

return 0;
}



⚠️ Возможные ошибки:

- Подключение <experimental/filesystem> вместо стандартного <filesystem> (устарело в C++17)
- Отсутствие обработки исключений — доступ к некоторым директориям может быть запрещён


Совет:

- Добавь try-catch вокруг итератора, если работаешь с произвольными путями
- Также удобно фильтровать файлы по расширению:
if (entry.path().extension() == ".cpp")



Библиотека C/C++ разработчика #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/cppproglib/5761
Create:
Last Update:

🗃 Работа с файлами и файловой системой в C++17

Хочешь получить список файлов в папке? std::filesystem предоставляет удобные итераторы для обхода директории. Особенно полезно при создании загрузчиков ассетов, инструментов или скриптов, работающих с файлами.


✏️ Решение:

1. заголовочный файл <filesystem>
2. Используй directory_iterator для обхода содержимого папки
3. Проверь тип объекта (файл, директория и т.д.), если нужно отфильтровать только файлы

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main() {
std::string path = "."; // текущая директория

for (const auto& entry : fs::directory_iterator(path)) {
if (fs::is_regular_file(entry)) {
std::cout << "Файл: " << entry.path() << std::endl;
}
else if (fs::is_directory(entry)) {
std::cout << "Папка: " << entry.path() << std::endl;
}
}

return 0;
}



⚠️ Возможные ошибки:

- Подключение <experimental/filesystem> вместо стандартного <filesystem> (устарело в C++17)
- Отсутствие обработки исключений — доступ к некоторым директориям может быть запрещён


Совет:

- Добавь try-catch вокруг итератора, если работаешь с произвольными путями
- Также удобно фильтровать файлы по расширению:
if (entry.path().extension() == ".cpp")



Библиотека C/C++ разработчика #буст

BY Библиотека C/C++ разработчика | cpp, boost, qt




Share with your friend now:
tg-me.com/cppproglib/5761

View MORE
Open in Telegram


Библиотека C C разработчика | cpp boost qt Telegram | DID YOU KNOW?

Date: |

Look for Channels Online

You guessed it – the internet is your friend. A good place to start looking for Telegram channels is Reddit. This is one of the biggest sites on the internet, with millions of communities, including those from Telegram.Then, you can search one of the many dedicated websites for Telegram channel searching. One of them is telegram-group.com. This website has many categories and a really simple user interface. Another great site is telegram channels.me. It has even more channels than the previous one, and an even better user experience.These are just some of the many available websites. You can look them up online if you’re not satisfied with these two. All of these sites list only public channels. If you want to join a private channel, you’ll have to ask one of its members to invite you.

What is Telegram Possible Future Strategies?

Cryptoassets enthusiasts use this application for their trade activities, and they may make donations for this cause.If somehow Telegram do run out of money to sustain themselves they will probably introduce some features that will not hinder the rudimentary principle of Telegram but provide users with enhanced and enriched experience. This could be similar to features where characters can be customized in a game which directly do not affect the in-game strategies but add to the experience.

Библиотека C C разработчика | cpp boost qt from es


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM USA